#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 通用装饰器函数，像权限校验、缓存、重试等
from functools import wraps
from flask import request, jsonify

def require_api_key(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        api_key = request.headers.get('X-API-KEY')
        if api_key != 'your-api-key':
            return jsonify({'error': 'Unauthorized'}), 401
        return func(*args, **kwargs)
    return wrapper
